package com.casi.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Created by IntelliJ IDEA.
 * User: hadoop
 * Date: 12-1-6
 * Time: 下午6:33
 * To change this template use File | Settings | File Templates.
 */
public class MysqlTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        Class.forName("com.mysql.jdbc.Driver");

        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/php_db", "root", "root");

        PreparedStatement stmt = conn.prepareStatement("insert into urls (url) values ('JAVA.......TEST.........')");
        long startTime=System.currentTimeMillis();
        for(int i=0;i<10000;i++) {
            stmt.execute();
        }



/*        // 4. 执行 SQL
        java.sql.ResultSet rs = stmt.executeQuery("select * from MyUser");

        // 5. 显示结果集里面的数据
        while(rs.next()) {
            System.out.println(rs.getInt(1));
            System.out.println(rs.getString("username"));
            System.out.println(rs.getString("password"));
            System.out.println();
        }*/

        // 6. 释放资源
       // rs.close();
        stmt.close();
        conn.close();
        System.out.println((System.currentTimeMillis()-startTime/1000.0));
    }
}
